package com.jeff.tianti.cms.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.jeff.tianti.common.entity.BaseEntity;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Entity
@Table(name = "job")//招聘职位表
@JsonIgnoreProperties(value={"columnInfo","company","hibernateLazyInitializer","handler","fieldHandler"})
public class Job extends BaseEntity {
    private static final long serialVersionUID = -5102241269833494278L;
    public static final String SPEAK_WELL = "0";
    public static final String DISCUSS_PERSONALLY = "1";
//    0->前端给  1->后台获取
    @Column(name = "uid")//用户id0
    private String uid;
    @Column(name = "publish_type")//发布类型0
    private String publishType;
    @Column(name = "job_name")//职位名称0
    private String jobName;
    private String jobType;//职位类别0
    private ColumnInfo columnInfo;
    private String columnInfoName;//职位类别名称
    @Column(name = "number")//招聘人数0
    private Integer number;
    @Column(name = "state")//0->讲好   1->面议0
    private String state;
    @Column(name = "money_min")
    private String moneyMin;//每月薪资    最低0
    @Column(name = "money_max")
    private String moneyMax;//每月薪资    最高0
    @Column(name = "educational_requirements")//学历要求0学历要求 0->不限 1->高中 2->技校 3->中专 4->大专 5->本科 6->硕士 7->博士
    private String educationalRequirements;
    private String educationalRequirementsString;
    @Column(name = "work_experience")//工作经验0工作经验  0->不限  1->一年以下 2->1-2年 3->3-5年 4->6-7年 5->8-10年 6->10-15年 7->15年以上
    private String workExperience;
    private String workExperienceString;
    @Column(name = "area_id")//地区id0
    private Integer areaId;
    @Column(name = "is_fresh_graduate")//是否接受应届生 0->不接受 1->接受
    private String isFreshGraduate;
    @Column(name = "provinces")//省市区0    江苏省 南京市 建邺区
    private String provinces;
    @Column(name = "longitud")//经度1
    private BigDecimal longitud;
    @Column(name = "latitude")//纬度1
    private BigDecimal latitude;

    @Column(name = "address")//详细地址0
    private String address;
    @Column(name = "job_description")//职位描述0
    private String jobDescription;
    @Column(name = "linkman")//联系人0
    private String linkman;
    @Column(name = "phone")//联系电话0
    private String phone;
    @Column(name = "e_mail")//联系邮箱0
    private String eMail;
    @Column(name = "gender")//性别0
    private String gender;

    private String companyId;
    @Column(name = "company_name")
    private String companyName;//公司名称0
    private Company company;
    @Transient
    public String getEducationalRequirementsString() {
//        学历要求0学历要求 0->不限 1->高中 2->技校 3->中专 4->大专 5->本科 6->硕士 7->博士
        if (educationalRequirements == null) {
            return "";
        }
        return "0".equals(educationalRequirements) ? "不限" : "1".equals(educationalRequirements) ? "高中" : "2".equals(educationalRequirements) ? "技校" : "3".equals(educationalRequirements) ? "中专" : "4".equals(educationalRequirements) ? "大专" : "5".equals(educationalRequirements) ? "本科" : "6".equals(educationalRequirements) ? "硕士" : "7".equals(educationalRequirements) ? "博士" : "";
    }

    public void setEducationalRequirementsString(String educationalRequirementsString) {
        this.educationalRequirementsString = educationalRequirementsString;
    }
    @Transient
    public String getWorkExperienceString() {
//        工作经验  0->不限  1->一年以下 2->1-2年 3->3-5年 4->6-7年 5->8-10年 6->10-15年 7->15年以上
        if (workExperience == null) {
            return "";
        }
        return "0".equals(workExperience) ? "不限" : "1".equals(workExperience) ? "一年以下" : "2".equals(workExperience) ? "1-2年" : "3".equals(workExperience) ? "3-5年" : "4".equals(workExperience) ? "6-7年" : "5".equals(workExperience) ? "8-10年" : "6".equals(workExperience) ? "10-15年" : "7".equals(workExperience) ? "15年以上" : "";
    }

    public void setWorkExperienceString(String workExperienceString) {
        this.workExperienceString = workExperienceString;
    }

    @Transient
    public String getColumnInfoName() {
        if (columnInfo != null) {
            return columnInfo.getName();
        }
        return "";
    }
    public void setColumnInfoName(String columnInfoName) {
        this.columnInfoName = columnInfoName;
    }

    public String getIsFreshGraduate() {
        return isFreshGraduate;
    }

    public void setIsFreshGraduate(String isFreshGraduate) {
        this.isFreshGraduate = isFreshGraduate;
    }

    @ManyToOne
    @JoinColumn(name = "company_id",insertable = false,updatable = false)
    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getMoneyMin() {
        return moneyMin;
    }

    public void setMoneyMin(String moneyMin) {
        this.moneyMin = moneyMin;
    }

    public String getMoneyMax() {
        return moneyMax;
    }

    public void setMoneyMax(String moneyMax) {
        this.moneyMax = moneyMax;
    }
    @Column(name = "company_id")//company表外键   一个公司对应多个职位，必须是先添加公司company表0
    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid == null ? null : uid.trim();
    }

    public String getPublishType() {
        return publishType;
    }

    public void setPublishType(String publishType) {
        this.publishType = publishType == null ? null : publishType.trim();
    }

    public String getJobName() {
        return jobName;
    }

    public void setJobName(String jobName) {
        this.jobName = jobName == null ? null : jobName.trim();
    }
    @Column(name = "job_type")//cms_column_info职位类别
    public String getJobType() {
        return jobType;
    }

    public void setJobType(String jobType) {
        this.jobType = jobType == null ? null : jobType.trim();

    }

    @ManyToOne(fetch = FetchType.LAZY,optional = false)
    @JoinColumn(name = "job_type",updatable = false,insertable = false)
    public ColumnInfo getColumnInfo() {
        return columnInfo;
    }

    public void setColumnInfo(ColumnInfo columnInfo) {
        this.columnInfo = columnInfo;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }
    public String getEducationalRequirements() {
        return educationalRequirements;
    }

    public void setEducationalRequirements(String educationalRequirements) {
        this.educationalRequirements = educationalRequirements == null ? null : educationalRequirements.trim();
    }

    public String getWorkExperience() {
        return workExperience;
    }

    public void setWorkExperience(String workExperience) {
        this.workExperience = workExperience == null ? null : workExperience.trim();
    }

    public Integer getAreaId() {
        return areaId;
    }

    public void setAreaId(Integer areaId) {
        this.areaId = areaId;
    }

    public String getProvinces() {
        return provinces;
    }

    public void setProvinces(String provinces) {
        this.provinces = provinces == null ? null : provinces.trim();
    }

    public BigDecimal getLongitud() {
        return longitud;
    }

    public void setLongitud(BigDecimal longitud) {
        this.longitud = longitud;
    }

    public BigDecimal getLatitude() {
        return latitude;
    }

    public void setLatitude(BigDecimal latitude) {
        this.latitude = latitude;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address == null ? null : address.trim();
    }

    public String getJobDescription() {
        return jobDescription;
    }

    public void setJobDescription(String jobDescription) {
        this.jobDescription = jobDescription == null ? null : jobDescription.trim();
    }

    public String getLinkman() {
        return linkman;
    }

    public void setLinkman(String linkman) {
        this.linkman = linkman == null ? null : linkman.trim();
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone == null ? null : phone.trim();
    }

    public String geteMail() {
        return eMail;
    }

    public void seteMail(String eMail) {
        this.eMail = eMail == null ? null : eMail.trim();
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender == null ? null : gender.trim();
    }
}